package com.cashmama.market.api.infras.app;

import com.cashmama.market.api.infras.enums.RestCodeEnum;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fqgj.common.api.ParamsObject;
import com.fqgj.exception.common.ApplicationException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

public class RequestBasicInfo extends ParamsObject {

    /**
     *
     */
    private static final long serialVersionUID = 3937282672478541910L;
    private String appKey;
    private String appVersion;
    private String appClient;
    private String net;
    private Long timestamp;
    private String appSign;
    private String token;

    /****
     * 业务线
     */
    private Integer bizCode;

    /*****
     * token版本号
     */
    private String tokenVersion;

    private Integer versionCode;
    private Integer ruleCode;
    private String channel;
    private String clientId;

    private String openId;
    private String guestId;
    private String from;
    private String appCode;
    private String categoryCode;
    @JsonProperty("package_name")
    private String packageName;
    @JsonProperty("mobile_imei")
    private String mobileImei;
    @JsonProperty("appsflyer_id")
    private String appsflyerId;

    public static boolean wechatUser(String channel) {
        if (StringUtils.isBlank(channel)) {
            return false;
        }
        return channel.startsWith("l");
    }

    @Override
    public void validate() {
        if (StringUtils.isEmpty(appVersion) || StringUtils.isEmpty(appClient)
                || timestamp == null || StringUtils.isEmpty(appSign)) {

            throw new ApplicationException(RestCodeEnum.SYSTEM_PARAMETER_ERROR);
        }
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
    }

    public String getAppKey() {
        return appKey;
    }

    public RequestBasicInfo setAppKey(String appKey) {
        this.appKey = appKey;
        return this;
    }

    public String getAppVersion() {
        return appVersion;
    }

    public RequestBasicInfo setAppVersion(String appVersion) {
        this.appVersion = appVersion;
        return this;
    }

    public String getAppClient() {
        return appClient;
    }

    public RequestBasicInfo setAppClient(String appClient) {
        this.appClient = appClient;
        return this;
    }

    public String getNet() {
        return net;
    }

    public RequestBasicInfo setNet(String net) {
        this.net = net;
        return this;
    }

    public Long getTimestamp() {
        return timestamp;
    }

    public RequestBasicInfo setTimestamp(Long timestamp) {
        this.timestamp = timestamp;
        return this;
    }

    public String getAppSign() {
        return appSign;
    }

    public RequestBasicInfo setAppSign(String appSign) {
        this.appSign = appSign;
        return this;
    }

    public String getToken() {
        return token;
    }

    public RequestBasicInfo setToken(String token) {
        this.token = token;
        return this;
    }

    public Integer getBizCode() {
        return bizCode;
    }

    public RequestBasicInfo setBizCode(Integer bizCode) {
        this.bizCode = bizCode;
        return this;
    }

    public String getTokenVersion() {
        return tokenVersion;
    }

    public RequestBasicInfo setTokenVersion(String tokenVersion) {
        this.tokenVersion = tokenVersion;
        return this;
    }

    public Integer getVersionCode() {
        return versionCode;
    }

    public RequestBasicInfo setVersionCode(Integer versionCode) {
        this.versionCode = versionCode;
        return this;
    }

    public Integer getRuleCode() {
        return ruleCode;
    }

    public RequestBasicInfo setRuleCode(Integer ruleCode) {
        this.ruleCode = ruleCode;
        return this;
    }

    public String getChannel() {
        return channel;
    }

    public RequestBasicInfo setChannel(String channel) {
        this.channel = channel;
        return this;
    }

    public String getClientId() {
        return clientId;
    }

    public RequestBasicInfo setClientId(String clientId) {
        this.clientId = clientId;
        return this;
    }

    public String getOpenId() {
        return openId;
    }

    public RequestBasicInfo setOpenId(String openId) {
        this.openId = openId;
        return this;
    }

    public String getGuestId() {
        return guestId;
    }

    public RequestBasicInfo setGuestId(String guestId) {
        this.guestId = guestId;
        return this;
    }

    public String getFrom() {
        return from;
    }

    public RequestBasicInfo setFrom(String from) {
        this.from = from;
        return this;
    }

    public String getAppCode() {
        return appCode;
    }

    public RequestBasicInfo setAppCode(String appCode) {
        this.appCode = appCode;
        return this;
    }

    public String getCategoryCode() {
        return categoryCode;
    }

    public RequestBasicInfo setCategoryCode(String categoryCode) {
        this.categoryCode = categoryCode;
        return this;
    }

    public String getPackageName() {
        return packageName;
    }

    public RequestBasicInfo setPackageName(String packageName) {
        this.packageName = packageName;
        return this;
    }

    public String getMobileImei() {
        return mobileImei;
    }

    public RequestBasicInfo setMobileImei(String mobileImei) {
        this.mobileImei = mobileImei;
        return this;
    }

    public String getAppsflyerId() {
        return appsflyerId;
    }

    public RequestBasicInfo setAppsflyerId(String appsflyerId) {
        this.appsflyerId = appsflyerId;
        return this;
    }
}
